package proj.reseau;


public class Fichier {
	private String fileName;
	private long taille;//en octets
	private int piece_size;
	private String key;//hash md5
	private BufferMap bufferMap=null;
	private String path;
	Fichier(String path, String nom, long taille, String key, int pieceSize)
	{
		this.fileName=nom;
		this.taille=taille;
		this.bufferMap= new BufferMap((int) Math.floor(((double)taille)/(double)pieceSize)+1);
		this.key=key;
		this.piece_size = pieceSize;
		this.path = path;
		
	}
	@Override
	public String toString() {
		return "Fichier [nom=" + fileName + ", taille=" + taille + ", piece_size="
				+ piece_size + ", key=" + key + "]";
	}
	
	public String getFormatedString()
	{
		return fileName+" "+taille+" "+piece_size+" "+key;
	}
	
	public BufferMap getBufferMap()
	{
		return bufferMap;
	}
	public String getKey()
	{
		if(key==null)
			return "";
		return key;
	}
	public void setSeedBuffMap()
	{
		bufferMap.setSeedBuffMap();
	}
	public void setBufferMap(String s)
	{
		bufferMap.setBufferMap(s);
	}
	public String getFileName() {
		return fileName;
	}
	public String getPath()
	{
		return path;
	}
	public long getTaille() {
		return taille;
	}
	public int getPiece_size() {
		return piece_size;
	}

}
